
string file = getenv("TMP1");
string DET = "dcTa";

void a(vector<TH2F *> &v, TObject *h){
  v.push_back((TH2F *)h);
} // end if

void dis2(){
  TFile *f = new TFile(file.c_str(), "UPDATE");
  TTree *etf = (TTree *)f->Get("etf");
  string det;
  string t0 = ".GetWireId():";
  string t1 = ".GetWireId()>>h";
  string t2 = "(19, -1.5, 17.5, 19, -1.5, 17.5)";
  string w1, w2, c;
  vector<TH2F *> v;

  // --------------------- 3. 2-D Wired Id Distribution ------------------------ //
  // dcTaU //
  det = DET + "U";
  w1 = det+"0Y0"; w2 = det+"0X0";
  c = w1+t0+w2+t1+"1"+t2; etf->Draw(c.c_str()); a(v,f->Get("h1"));
  w1 = det+"0Y1"; w2 = det+"0X1";
  c = w1+t0+w2+t1+"2"+t2; etf->Draw(c.c_str()); a(v,f->Get("h2"));
  w1 = det+"1Y0"; w2 = det+"1X0";
  c = w1+t0+w2+t1+"3"+t2; etf->Draw(c.c_str()); a(v,f->Get("h3"));
  w1 = det+"1Y1"; w2 = det+"1X1";
  c = w1+t0+w2+t1+"4"+t2; etf->Draw(c.c_str()); a(v,f->Get("h4"));
  // dcTaD //
  det = DET + "D";
  w1 = det+"0Y0"; w2 = det+"0X0";
  c = w1+t0+w2+t1+"5"+t2; etf->Draw(c.c_str()); a(v,f->Get("h5"));
  w1 = det+"0Y1"; w2 = det+"0X1";
  c = w1+t0+w2+t1+"6"+t2; etf->Draw(c.c_str()); a(v,f->Get("h6"));
  w1 = det+"1Y0"; w2 = det+"1X0";
  c = w1+t0+w2+t1+"7"+t2; etf->Draw(c.c_str()); a(v,f->Get("h7"));
  w1 = det+"1Y1"; w2 = det+"1X1";
  c = w1+t0+w2+t1+"8"+t2; etf->Draw(c.c_str()); a(v,f->Get("h8"));

  TCanvas *c1 = new TCanvas("c", "2-D Wire Id Distribution", 1680, 1050);
  c1->Divide(2,2);
  for(int i = 0; i < 4; i++){
    c1->cd(i+1); v[i]->Draw("colzboxtext");
    v[i]->GetXaxis()->SetTitle("X wire Id");
    v[i]->GetYaxis()->SetTitle("Y wire Id");
  } // end for
  c1->Print("dis2.pdf");
} // end vis
